#include<bits/stdc++.h>
using namespace std;
int n,m,a[114][4],ans;
int main(){
	freopen("c.in","r",stdin);
	freopen("c.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=m;++i)
	for(int j=0;j<4;++j) cin>>a[i][j];
	for(int x=1;x<=n;++x)
	for(int y=1;y<=n;++y)
	for(int z=1;z<=n;++z)
	for(int d=1;d<=n;++d){
		int ok=1;
		for(int i=1;i<=m;++i){
			int c=(x>a[i][0])+(y>a[i][1])+(z>a[i][2])+(d>a[i][3]);
			if(c<3) ok=0;
		}
		ans+=ok;
	}
	cout<<ans;
	return 0;
}


